<template>
  <div class="home">
    <img alt="Vue logo" src="../assets/logo.png" />
    <HelloWorld msg="Welcome to Your Vue.js App" />
    <div @click="clickHandle">Hello，小白。点击我测试一下！</div>
    <div>{{res}}</div>
  </div>
</template>

<script>
// @ is an alias to /src
import HelloWorld from "@/components/HelloWorld.vue";
import yesapi from "@/components/yesapi";
import axios from "axios";

export default {
  name: "Home",
  data() {
    return {
      res: ""
    };
  },
  components: {
    HelloWorld
  },
  methods: {
    clickHandle() {
      var params = {
        s: "App.Hello.World",
        name: "hello，小白"
      };
      var that = this;
      axios({
        method: "get",
        url: yesapi.YESAPI_HOST,
        params: yesapi.encrypt(params)
      })
        .then(function(response) {
          console.log(response);
          that.res = response.data;
        })
        .catch(function(error) {
          console.log(error);
        });
    }
  }
};
</script>
